package net.cohoivang.user;

public enum MyLanguages {
	en(1, "English", "en"),
	vn(2, "Tiếng Việt", "vn"),
	ch(3, "中文", "CH");
	
	
	public final int id;
	public final String caption;
	public final String code;
	private MyLanguages(int id, String caption, String code) {
		this.id = id;
		this.caption = caption;
		this.code = code;
	}
	
	public int getId() {
		return this.id;
	}
	
	public String getCaption() {
		return this.caption;
	}
	
	public String getCode() {
		return this.code;
	}
	
	public static MyLanguages getMyLanguages(String code) {
		if (code.equals(en.code)) {
			return en;
		} else if (code.equals(vn.code)) {
			return vn;
		} else if (code.equals(ch.code)) {
			return ch;
		} else {
			return null;
		}
	}
	
	public static MyLanguages getMyLanguages(int id) {
		if (id == en.id) {
			return MyLanguages.en;
		} else if (id == ch.id) {
			return MyLanguages.ch;
		} else if (id == vn.id) {
			return MyLanguages.vn;
		} else {
			return null;
		}
	}
}
